package com.heima.comment.controller;

import com.heima.comment.service.ApCommentRepayService;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.comment.dtos.CommentReplyLikeDto;
import com.heima.model.comment.dtos.CommentReplyLoadDTO;
import com.heima.model.comment.dtos.CommentReplySaveDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Fuqiang
 * @since :2023-04-10
 */
@RestController
@RequestMapping("/api/v1/comment_reply")
public class CommentRepayController {

    @Autowired
    ApCommentRepayService commentRepayService;

    /**
     * 保存app文章评论回复内容
     *
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody @Validated CommentReplySaveDto dto) {
        commentRepayService.save(dto);
        return ResponseResult.ok();
    }

    /**
     * 加载评论回复列表
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody @Validated CommentReplyLoadDTO dto) {

        return ResponseResult.ok(commentRepayService.load(dto));
    }

    /**
     * 点赞或取消点赞
     *
     * @param dto
     * @return
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody @Validated CommentReplyLikeDto dto) {

        return ResponseResult.ok(commentRepayService.like(dto));
    }

}
